﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Foothill.Bus.Node;
using Foothill.Persistent.Command;
using Foothill.Bus;
using Foothill.Bus.Result;
using Foothill.Utils;
using GGFW.Entity.SystemManage;
using GGFW.DataAccess.Constants;

namespace GGFW.DataAccess.SystemManage
{
    public class UserDao : IDisposable
    {
        #region 更改用户密码
        /// <summary>
        /// 更改用户密码
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="NewPwd"></param>
        /// <returns></returns>
        public bool UpdatePwd(int UserID, string NewPwd)
        {
            string sql = string.Format("Update FoothillUser set Password='{0}' Where UserID={1}", NewPwd, UserID);
            //设置查询企业基本信息总线
            NativeSqlBus queryBus = new NativeSqlBus("FoothillUser", sql);


            //执行查询业务代码命令
            QueryNativeSqlCommand queryCommand = new QueryNativeSqlCommand(queryBus);
            ResultQueryNativeSql result = queryCommand.execute() as ResultQueryNativeSql;

            //执行结果为空
            if (result == null)
            {
                throw new Exception(Common.UNKNOW_DB_ERROR);
            }

            //执行命令不成功
            if (!result.isSuccess())
            {
                throw new Exception(result.getMessage());
            }

            return true;
        }
        #endregion

        #region IDisposable 成员

        public void Dispose()
        {
        }

        #endregion
    }
}
